package hr.fer.zpr.nmbp.project3.model.util;
import java.io.File;
import java.io.IOException;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.SchemaOutputResolver;
import javax.xml.transform.stream.StreamResult;

public class JAXB extends SchemaOutputResolver {
		 
		    public javax.xml.transform.Result createOutput(String namespaceURI, String suggestedFileName) throws IOException {
		        File file = new File("file.xsd");
		        StreamResult result = new StreamResult(file);
		        result.setSystemId(file.toURI().toURL().toString());
		        return result;
		    }
		    
			public static void main(String[] args) {
				System.out.println("1\n");
		    	@SuppressWarnings("rawtypes")
				Class[] classes = new Class[6];
		    	
		    	classes[0] = hr.fer.zpr.nmbp.project3.model.Bolest.class; 
		    	classes[1] = hr.fer.zpr.nmbp.project3.model.Bolnica.class; 
		    	classes[2] = hr.fer.zpr.nmbp.project3.model.Pacijent.class; 
		    	classes[3] = hr.fer.zpr.nmbp.project3.model.Lijecnik.class;
		    	classes[4] = hr.fer.zpr.nmbp.project3.model.Dijagnoza.class; 
		    	classes[5] = hr.fer.zpr.nmbp.project3.model.Karton.class; 
		    	

		    	 
		    	SchemaOutputResolver sor = new JAXB();
		    	try {
		    		JAXBContext jaxbContext = JAXBContext.newInstance(classes);
					jaxbContext.generateSchema(sor);
			    	
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (JAXBException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		    }
				
}
